//树状数组 - 物流 Logistics
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define lowbit(x) (x & -x)
const int N = 1e6 + 10;
typedef long long ll;
int n, m;
unordered_map<int, int> mp;

struct node
{
    char op;
    int x, y;
}q[N];

ll a[N], t[N];

struct BIT
{
    ll s[N];
    void modify(int x, int k)
    {
        for(int i = x; i <= m; i += lowbit(i)) s[i] += k;
    }

    ll query(int x)
    {
        ll sum = 0;
        for(int i = x; i; i -= lowbit(i)) sum += s[i];
        return sum;
    }
}A, B;

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++)
    {
        scanf(" %c", &q[i].op);
        scanf("%d%d", &q[i].x, &q[i].y);
        t[i] = q[i].y;
    }

    //离散化
    sort(t + 1, t + 1 + m);
    for(int i = 1; i <= m; i++) mp[t[i]] = i;

    for(int i = 1; i <= m; i++)
    {
        char op = q[i].op;
        if(op == 'U')
        {
            int x = q[i].x, k = q[i].y;
            if(a[x])
            {
                A.modify(mp[a[x]], -a[x]); 
                B.modify(mp[a[x]], -1); 
            }
            A.modify(mp[k], k);
            B.modify(mp[k], 1);
            a[x] = k;
        }
        else
        {
            //sum >= (c - cnt) * s
            int c = q[i].x, s = q[i].y;
            ll sum = A.query(mp[s] - 1);
            ll cnt = B.query(m) - B.query(mp[s] - 1);
            if(sum >= (c - cnt) * s) printf("%s\n", "TAK");
            else printf("NIE\n");
        }
    }
    return 0;
}
